12312 => 'testing',
],
'wgContentHandlers' => [
- CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler',
- CONTENT_MODEL_JAVASCRIPT => 'JavaScriptContentHandler',
- CONTENT_MODEL_JSON => 'JsonContentHandler',
- CONTENT_MODEL_CSS => 'CssContentHandler',
- CONTENT_MODEL_TEXT => 'TextContentHandler',
- 'testing' => 'DummyContentHandlerForTesting',
+ CONTENT_MODEL_WIKITEXT => WikitextContentHandler::class,
+ CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class,
+ CONTENT_MODEL_JSON => JsonContentHandler::class,
+ CONTENT_MODEL_CSS => CssContentHandler::class,
+ CONTENT_MODEL_TEXT => TextContentHandler::class,
+ 'testing' => DummyContentHandlerForTesting::class,
'testing-callbacks' => function ( $modelId ) {
return new DummyContentHandlerForTesting( $modelId );
}
] );
// Reset namespace cache
- MWNamespace::getCanonicalNamespaces( true );
+ MWNamespace::clearCaches();
$wgContLang->resetNamespaces();
// And LinkCache
MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
global $wgContLang;
// Reset namespace cache
- MWNamespace::getCanonicalNamespaces( true );
+ MWNamespace::clearCaches();
$wgContLang->resetNamespaces();
// And LinkCache
MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
$this->assertNull( $text );
}
- /*
- public static function makeContent( $text, Title $title, $modelId = null, $format = null ) {}
- */
-
public static function dataMakeContent() {
return [
[ 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ],
}
}
- /*
+ /**
+ * @covers ContentHandler::getAutosummary
+ *
* Test if we become a "Created blank page" summary from getAutoSummary if no Content added to
* page.
*/
$content = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
$title = Title::newFromText( 'Help:Test' );
// Create a new content object with no content
- $newContent = ContentHandler::makeContent( '', $title, null, null, CONTENT_MODEL_WIKITEXT );
+ $newContent = ContentHandler::makeContent( '', $title, CONTENT_MODEL_WIKITEXT, null );
// first check, if we become a blank page created summary with the right bitmask
$autoSummary = $content->getAutosummary( null, $newContent, 97 );
- $this->assertEquals( $autoSummary, 'Created blank page' );
+ $this->assertEquals( $autoSummary,
+ wfMessage( 'autosumm-newblank' )->inContentLanguage()->text() );
// now check, what we become with another bitmask
$autoSummary = $content->getAutosummary( null, $newContent, 92 );
$this->assertEquals( $autoSummary, '' );
}
- /*
- public function testSupportsSections() {
- $this->markTestIncomplete( "not yet implemented" );
+ /**
+ * Test software tag that is added when content model of the page changes
+ * @covers ContentHandler::getChangeTag
+ */
+ public function testGetChangeTag() {
+ $this->setMwGlobals( 'wgSoftwareTags', [ 'mw-contentmodelchange' => true ] );
+ $wikitextContentHandler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
+ // Create old content object with javascript content model
+ $oldContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_JAVASCRIPT, null );
+ // Create new content object with wikitext content model
+ $newContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_WIKITEXT, null );
+ // Get the tag for this edit
+ $tag = $wikitextContentHandler->getChangeTag( $oldContent, $newContent, EDIT_UPDATE );
+ $this->assertSame( $tag, 'mw-contentmodelchange' );
}
- */
+ /**
+ * @covers ContentHandler::supportsCategories
+ */
public function testSupportsCategories() {
$handler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
$this->assertTrue( $handler->supportsCategories(), 'content model supports categories' );
}
+ /**
+ * @covers ContentHandler::supportsDirectEditing
+ */
public function testSupportsDirectEditing() {
$handler = new DummyContentHandlerForTesting( CONTENT_MODEL_JSON );
$this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' );
public function provideGetModelForID() {
return [
- [ CONTENT_MODEL_WIKITEXT, 'WikitextContentHandler' ],
- [ CONTENT_MODEL_JAVASCRIPT, 'JavaScriptContentHandler' ],
- [ CONTENT_MODEL_JSON, 'JsonContentHandler' ],
- [ CONTENT_MODEL_CSS, 'CssContentHandler' ],
- [ CONTENT_MODEL_TEXT, 'TextContentHandler' ],
- [ 'testing', 'DummyContentHandlerForTesting' ],
- [ 'testing-callbacks', 'DummyContentHandlerForTesting' ],
+ [ CONTENT_MODEL_WIKITEXT, WikitextContentHandler::class ],
+ [ CONTENT_MODEL_JAVASCRIPT, JavaScriptContentHandler::class ],
+ [ CONTENT_MODEL_JSON, JsonContentHandler::class ],
+ [ CONTENT_MODEL_CSS, CssContentHandler::class ],
+ [ CONTENT_MODEL_TEXT, TextContentHandler::class ],
+ [ 'testing', DummyContentHandlerForTesting::class ],
+ [ 'testing-callbacks', DummyContentHandlerForTesting::class ],
];
}
/**
+ * @covers ContentHandler::getForModelID
* @dataProvider provideGetModelForID
*/
public function testGetModelForID( $modelId, $handlerClass ) {
$this->assertInstanceOf( $handlerClass, $handler );
}
+ /**
+ * @covers ContentHandler::getFieldsForSearchIndex
+ */
public function testGetFieldsForSearchIndex() {
$searchEngine = $this->newSearchEngine();
}
private function newSearchEngine() {
- $searchEngine = $this->getMockBuilder( 'SearchEngine' )
+ $searchEngine = $this->getMockBuilder( SearchEngine::class )
->getMock();
$searchEngine->expects( $this->any() )
* @covers ContentHandler::getDataForSearchIndex
*/
public function testDataIndexFields() {
- $mockEngine = $this->createMock( 'SearchEngine' );
+ $mockEngine = $this->createMock( SearchEngine::class );
$title = Title::newFromText( 'Not_Main_Page', NS_MAIN );
$page = new WikiPage( $title );